Skip to content

Create examples for HardwareTimer library #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2019
Merged

Conversation

ABOSTM
Copy link
Contributor

@ABOSTM ABOSTM commented Jul 26, 2019

Examples

Following examples are provided in STM32Examples library (available with Arduino Library manager).
Requirement: HardwareTimer library

  • Timebase_callback.ino

    This example shows how to configure HardwareTimer to execute a callback at regular interval.
    Callback toggles pin.
    Once configured, there is only CPU load for callbacks executions.

  • PWM_FullConfiguration.ino

    This example shows how to fully configure a PWM with HardwareTimer.
    PWM is generated on LED_BUILTIN if available.
    PWM is generated by hardware: no CPU load.
    Nevertheless, in this example both interruption callback are used on Compare match (Falling edge of PWM1 mode) and update event (rising edge of PWM1 mode).
    Those call back are used to toggle a second pin: pin2.
    Once configured, there is only CPU load for callbacks executions.

  • All-in-one_setPWM.ino

    This example shows how to configure a PWM with HardwareTimer in one single function call.
    PWM is generated on LED_BUILTIN if available.
    No interruption callback used: PWM is generated by hardware.
    Once configured, there is no CPU load.

  • InputCapture.ino

    This example shows how to configure HardwareTimer in inputcapture to measure external signal frequency.
    Each time a rising edge is detected on the input pin, hardware will save counter value into CaptureCompare register.
    External signal (signal generator for example) should be connected to D2.
    Measured frequency is displayed on Serial Monitor.

  • Frequency_Dutycycle_measurement.ino

    This example shows how to configure HardwareTimer to measure external signal frequency and dutycycle.
    The input pin will be connected to 2 channel of the timer, one for rising edge the other for falling edge.
    Each time a rising edge is detected on the input pin, hardware will save counter value into one of the CaptureCompare register.
    Each time a falling edge is detected on the input pin, hardware will save counter value into the other CaptureCompare register.
    External signal (signal generator for example) should be connected to D2.

@fpistm fpistm merged commit b7632c4 into stm32duino:master Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants